#!/usr/bin/env python
# -*- coding: latin-1 -*-

import pefile,sys
import re

if len(sys.argv)==1:
	print "Provide some argument..."
	sys.exit()

pe =  pefile.PE(sys.argv[1])

html="""
Locale identifier	Primary language	Prim. lang. identifier	Prim. lang. symbol	Sublanguage	Sublang. identifier	Sublang. symbol
0x0C00	Default custom locale language	0x00	LANG_NEUTRAL	Default custom sublanguage	0x03	SUBLANG_CUSTOM_DEFAULT
0x1400	Default custom MUI locale language	0x00	LANG_NEUTRAL	Default custom MUI sublanguage	0x05	SUBLANG_UI_CUSTOM_DEFAULT
0x007F	Invariant locale language	0x7F	LANG_INVARIANT	Invariant sublanguage	0x00	SUBLANG_NEUTRAL
0x0000	Neutral locale language	0x00	LANG_NEUTRAL	Neutral sublanguage	0x00	SUBLANG_NEUTRAL
0x0800	System default locale language	0x02	LANG_SYSTEM_DEFAULT	System default sublanguage	0x02	SUBLANG_SYS_DEFAULT
0x1000	Unspecified custom locale language	0x00	LANG_NEUTRAL	Unspecified custom sublanguage	0x04	SUBLANG_CUSTOM_UNSPECIFIED
0x0400	User default locale language	0x00	LANG_USER_DEFAULT	User default sublanguage	0x01	SUBLANG_DEFAULT
0x0436	Afrikaans (af)	0x36	LANG_AFRIKAANS	South Africa (ZA)	0x01	SUBLANG_AFRIKAANS_SOUTH_AFRICA
0x041C	Albanian (sq)	0x1c	LANG_ALBANIAN	Albania (AL)	0x01	SUBLANG_ALBANIAN_ALBANIA
0x0484	Alsatian (gsw)	0x84	LANG_ALSATIAN	France (FR)	0x01	SUBLANG_ALSATIAN_FRANCE
0x045E	Amharic (am)	0x5E	LANG_AMHARIC	Ethiopia (ET)	0x01	SUBLANG_AMHARIC_ETHIOPIA
0x1401	Arabic (ar)	0x01	LANG_ARABIC	Algeria (DZ)	0x05	SUBLANG_ARABIC_ALGERIA
0x3C01				Bahrain (BH)	0x0f	SUBLANG_ARABIC_BAHRAIN
0x0C01				Egypt (EG)	0x03	SUBLANG_ARABIC_EGYPT
0x0801				Iraq (IQ)	0x02	SUBLANG_ARABIC_IRAQ
0x2C01				Jordan (JO)	0x0B	SUBLANG_ARABIC_JORDAN
0x3401				Kuwait (KW)	0x0D	SUBLANG_ARABIC_KUWAIT
0x3001				Lebanon (LB)	0x0C	SUBLANG_ARABIC_LEBANON
0x1001				Libya (LY)	0x04	SUBLANG_ARABIC_LIBYA
0x1801				Morocco (MA)	0x06	SUBLANG_ARABIC_MOROCCO
0x2001				Oman (OM)	0x08	SUBLANG_ARABIC_OMAN
0x4001				Qatar (QA)	0x10	SUBLANG_ARABIC_QATAR
0x0401				Saudi Arabia (SA)	0x01	SUBLANG_ARABIC_SAUDI_ARABIA
0x2801				Syria (SY)	0x0A	SUBLANG_ARABIC_SYRIA
0x1C01				Tunisia (TN)	0x07	SUBLANG_ARABIC_TUNISIA
0x3801				U.A.E. (AE)	0x0E	SUBLANG_ARABIC_UAE
0x2401				Yemen (YE)	0x09	SUBLANG_ARABIC_YEMEN
0x042B	Armenian (hy)	0x2B	LANG_ARMENIAN	Armenia (AM)	0x01	SUBLANG_ARMENIAN_ARMENIA
0x044D	Assamese (as)	0x4D	LANG_ASSAMESE	India (IN)	0x01	SUBLANG_ASSAMESE_INDIA
0x082C	Azeri (az)	0x2C	LANG_AZERI	Azerbaijan, Cyrillic (AZ)	0x02	SUBLANG_AZERI_CYRILLIC
0x042C				Azerbaijan, Latin (AZ)	0x01	SUBLANG_AZERI_LATIN
0x0445	Bangla (bn); see note 10	0x45	LANG_BANGLA	Bangladesh	0x02	SUBLANG_BANGLA_BANGLADESH
India (IN)	0x01	SUBLANG_BANGLA_INDIA
0x046D	Bashkir (ba)	0x6D	LANG_BASHKIR	Russia (RU)	0x01	SUBLANG_BASHKIR_RUSSIA
0x042D	Basque (eu)	0x2d	LANG_BASQUE	Basque (ES)	0x01	SUBLANG_BASQUE_BASQUE
0x0423	Belarusian (be)	0x23	LANG_BELARUSIAN	Belarus (BY)	0x01	SUBLANG_BELARUSIAN_BELARUS
0x781A	Bosnian (bs)		LANG_BOSNIAN_NEUTRAL	Neutral		
0x201A	Bosnian (bs); see note 2	0x1A	LANG_BOSNIAN	Bosnia and Herzegovina, Cyrillic (BA)	0x08	SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_CYRILLIC
0x141A				Bosnia and Herzegovina, Latin (BA)	0x05	SUBLANG_BOSNIAN_BOSNIA_HERZEGOVINA_LATIN
0x047E	Breton (br)	0x7E	LANG_BRETON	France (FR)	0x01	SUBLANG_BRETON_FRANCE
0x0402	Bulgarian (bg)	0x02	LANG_BULGARIAN	Bulgaria (BG)	0x01	SUBLANG_BULGARIAN_BULGARIA
0x0492	Central Kurdish (ku)	0x92	LANG_CENTRAL_KURDISH	Iraq (IQ)	0x01	SUBLANG_CENTRAL_KURDISH_IRAQ
0x045C	Cherokee (chr)	0x5C	LANG_CHEROKEE	Cherokee (Cher)	0x01	SUBLANG_CHEROKEE_CHEROKEE
0x0403	Catalan (ca)	0x03	LANG_CATALAN	Spain (ES)	0x01	SUBLANG_CATALAN_CATALAN
0x0C04	Chinese (zh); see note 1	0x04	LANG_CHINESE	Hong Kong SAR, PRC (HK)	0x03	SUBLANG_CHINESE_HONGKONG
0x1404				Macao SAR (MO)	0x05	SUBLANG_CHINESE_MACAU
0x1004				Singapore (SG)	0x04	SUBLANG_CHINESE_SINGAPORE
0x0004	Chinese (zh)	0x04	LANG_CHINESE_SIMPLIFIED	Simplified (Hans)	0x02	SUBLANG_CHINESE_SIMPLIFIED
0x7C04	Chinese (zh)		LANG_CHINESE_TRADITIONAL	Traditional (Hant)	0x01	SUBLANG_CHINESE_TRADITIONAL
0x0483	Corsican (co)	0x83	LANG_CORSICAN	France (FR)	0x01	SUBLANG_CORSICAN_FRANCE
0x001A	Croatian (hr); see note 2	0x1A	LANG_CROATIAN	Neutral		
0x101A	Croatian (hr)	0x1a	LANG_CROATIAN	Bosnia and Herzegovina, Latin (BA)	0x04	SUBLANG_CROATIAN_BOSNIA_HERZEGOVINA_LATIN
0x041A				Croatia (HR)	0x01	SUBLANG_CROATIAN_CROATIA
0x0405	Czech (cs)	0x05	LANG_CZECH	Czech Republic (CZ)	0x01	SUBLANG_CZECH_CZECH_REPUBLIC
0x0406	Danish (da)	0x06	LANG_DANISH	Denmark (DK)	0x01	SUBLANG_DANISH_DENMARK
0x048C	Dari (prs)	0x8C	LANG_DARI	Afghanistan (AF)	0x01	SUBLANG_DARI_AFGHANISTAN
0x0465	Divehi (dv)	0x65	LANG_DIVEHI	Maldives (MV)	0x01	SUBLANG_DIVEHI_MALDIVES
0x0813	Dutch (nl)	0x13	LANG_DUTCH	Belgium (BE)	0x02	SUBLANG_DUTCH_BELGIAN
0x0413				Netherlands (NL)	0x01	SUBLANG_DUTCH
0x0C09	English (en)	0x09	LANG_ENGLISH	Australia (AU)	0x03	SUBLANG_ENGLISH_AUS
0x2809				Belize (BZ)	0x0A	SUBLANG_ENGLISH_BELIZE
0x1009				Canada (CA)	0x04	SUBLANG_ENGLISH_CAN
0x2409				Caribbean (029)	0x09	SUBLANG_ENGLISH_CARIBBEAN
0x4009				India (IN)	0x10	SUBLANG_ENGLISH_INDIA
0x1809				Ireland (IE); see note 3	0x06	SUBLANG_ENGLISH_EIRE
0x1809				Ireland (IE); see note 3	0x06	SUBLANG_ENGLISH_IRELAND
0x2009				Jamaica (JM)	0x08	SUBLANG_ENGLISH_JAMAICA
0x4409				Malaysia (MY)	0x11	SUBLANG_ENGLISH_MALAYSIA
0x1409				New Zealand (NZ)	0x05	SUBLANG_ENGLISH_NZ
0x3409				Philippines (PH)	0x0D	SUBLANG_ENGLISH_PHILIPPINES
0x4809				Singapore (SG)	0x12	SUBLANG_ENGLISH_SINGAPORE
0x1c09				South Africa (ZA)	0x07	SUBLANG_ENGLISH_SOUTH_AFRICA
0x2C09				Trinidad and Tobago (TT)	0x0B	SUBLANG_ENGLISH_TRINIDAD
0x0809				United Kingdom (GB)	0x02	SUBLANG_ENGLISH_UK
0x0409				United States (US)	0x01	SUBLANG_ENGLISH_US
0x3009				Zimbabwe (ZW)	0x0C	SUBLANG_ENGLISH_ZIMBABWE
0x0425	Estonian (et)	0x25	LANG_ESTONIAN	Estonia (EE)	0x01	SUBLANG_ESTONIAN_ESTONIA
0x0438	Faroese (fo)	0x38	LANG_FAEROESE	Faroe Islands (FO)	0x01	SUBLANG_FAEROESE_FAROE_ISLANDS
0x0464	Filipino (fil)	0x64	LANG_FILIPINO	Philippines (PH)	0x01	SUBLANG_FILIPINO_PHILIPPINES
0x040B	Finnish (fi)	0x0B	LANG_FINNISH	Finland (FI)	0x01	SUBLANG_FINNISH_FINLAND
0x080c	French (fr)	0x0C	LANG_FRENCH	Belgium (BE)	0x02	SUBLANG_FRENCH_BELGIAN
0x0C0C				Canada (CA)	0x03	SUBLANG_FRENCH_CANADIAN
0x040c				France (FR)	0x01	SUBLANG_FRENCH
0x140C				Luxembourg (LU)	0x05	SUBLANG_FRENCH_LUXEMBOURG
0x180C				Monaco (MC)	0x06	SUBLANG_FRENCH_MONACO
0x100C				Switzerland (CH)	0x04	SUBLANG_FRENCH_SWISS
0x0462	Frisian (fy)	0x62	LANG_FRISIAN	Netherlands (NL)	0x01	SUBLANG_FRISIAN_NETHERLANDS
0x0456	Galician (gl)	0x56	LANG_GALICIAN	Spain (ES)	0x01	SUBLANG_GALICIAN_GALICIAN
0x0437	Georgian (ka)	0x37	LANG_GEORGIAN	Georgia (GE)	0x01	SUBLANG_GEORGIAN_GEORGIA
0x0C07	German (de)	0x07	LANG_GERMAN	Austria (AT)	0x03	SUBLANG_GERMAN_AUSTRIAN
0x0407				Germany (DE)	0x01	SUBLANG_GERMAN
0x1407				Liechtenstein (LI)	0x05	SUBLANG_GERMAN_LIECHTENSTEIN
0x1007				Luxembourg (LU)	0x04	SUBLANG_GERMAN_LUXEMBOURG
0x0807				Switzerland (CH)	0x02	SUBLANG_GERMAN_SWISS
0x0408	Greek (el)	0x08	LANG_GREEK	Greece (GR)	0x01	SUBLANG_GREEK_GREECE
0x046F	Greenlandic (kl)	0x6F	LANG_GREENLANDIC	Greenland (GL)	0x01	SUBLANG_GREENLANDIC_GREENLAND
0x0447	Gujarati (gu)	0x47	LANG_GUJARATI	India (IN)	0x01	SUBLANG_GUJARATI_INDIA
0x0468	Hausa (ha)	0x68	LANG_HAUSA	Nigeria (NG)	0x01	SUBLANG_HAUSA_NIGERIA_LATIN
0x0475	Hawiian (haw)	0x75	LANG_HAWAIIAN	United States (US)	0x01	SUBLANG_HAWAIIAN_US
0x040D	Hebrew (he)	0x0D	LANG_HEBREW	Israel (IL)	0x01	SUBLANG_HEBREW_ISRAEL
0x0439	Hindi (hi)	0x39	LANG_HINDI	India (IN)	0x01	SUBLANG_HINDI_INDIA
0x040E	Hungarian (hu)	0x0E	LANG_HUNGARIAN	Hungary (HU)	0x01	SUBLANG_HUNGARIAN_HUNGARY
0x040F	Icelandic (is)	0x0F	LANG_ICELANDIC	Iceland (IS)	0x01	SUBLANG_ICELANDIC_ICELAND
0x0470	Igbo (ig)	0x70	LANG_IGBO	Nigeria (NG)	0x01	SUBLANG_IGBO_NIGERIA
0x0421	Indonesian (id)	0x21	LANG_INDONESIAN	Indonesia (ID)	0x01	SUBLANG_INDONESIAN_INDONESIA
0x085D	Inuktitut (iu)	0x5D	LANG_INUKTITUT	Canada (CA), Latin	0x02	SUBLANG_INUKTITUT_CANADA_LATIN
0x045D				Canada (CA), Canadian Syllabics	0x01	SUBLANG_INUKTITUT_CANADA
0x083C	Irish (ga); see note 4	0x3C	LANG_IRISH	Ireland (IE)	0x02	SUBLANG_IRISH_IRELAND
0x0434	isiXhosa (xh)	0x34	LANG_XHOSA	South Africa (ZA)	0x01	SUBLANG_XHOSA_SOUTH_AFRICA
0x0435	isiZulu (zu)	0x35	LANG_ZULU	South Africa (ZA)	0x01	SUBLANG_ZULU_SOUTH_AFRICA
0x0410	Italian (it)	0x10	LANG_ITALIAN	Italy (IT)	0x01	SUBLANG_ITALIAN
0x0810				Switzerland (CH)	0x02	SUBLANG_ITALIAN_SWISS
0x0411	Japanese (ja)	0x11	LANG_JAPANESE	Japan (JP)	0x01	SUBLANG_JAPANESE_JAPAN
0x044B	Kannada (kn)	0x4B	LANG_KANNADA	India (IN)	0x01	SUBLANG_KANNADA_INDIA
______	(reserved)	0x60	LANG_KASHMIRI	(reserved)	0x02	SUBLANG_KASHMIRI_INDIA
(reserved)	0x02	SUBLANG_KASHMIRI_SASIA
0x043F	Kazakh (kk)	0x3F	LANG_KAZAK	Kazakhstan (KZ)	0x01	SUBLANG_KAZAK_KAZAKHSTAN
0x0453	Khmer (kh)	0x53	LANG_KHMER	Cambodia (KH)	0x01	SUBLANG_KHMER_CAMBODIA
0x0486	K'iche (qut)	0x86	LANG_KICHE	Guatemala (GT)	0x01	SUBLANG_KICHE_GUATEMALA
0x0487	Kinyarwanda (rw)	0x87	LANG_KINYARWANDA	Rwanda (RW)	0x01	SUBLANG_KINYARWANDA_RWANDA
0x0457	Konkani (kok)	0x57	LANG_KONKANI	India (IN)	0x01	SUBLANG_KONKANI_INDIA
0x0412	Korean (ko)	0x12	LANG_KOREAN	Korea (KR)	0x01	SUBLANG_KOREAN
0x0440	Kyrgyz (ky)	0x40	LANG_KYRGYZ	Kyrgyzstan (KG)	0x01	SUBLANG_KYRGYZ_KYRGYZSTAN
0x0454	Lao (lo)	0x54	LANG_LAO	Lao PDR (LA)	0x01	SUBLANG_LAO_LAO
0x0426	Latvian (lv)	0x26	LANG_LATVIAN	Latvia (LV)	0x01	SUBLANG_LATVIAN_LATVIA
0x0427	Lithuanian (lt)	0x27	LANG_LITHUANIAN	Lithuanian (LT); see note 5	0x01	SUBLANG_LITHUANIAN_LITHUANIA
0x082E	Lower Sorbian (dsb)	0x2E	LANG_LOWER_SORBIAN	Germany (DE)	0x02	SUBLANG_LOWER_SORBIAN_GERMANY
0x046E	Luxembourgish (lb)	0x6E	LANG_LUXEMBOURGISH	Luxembourg (LU)	0x01	SUBLANG_LUXEMBOURGISH_LUXEMBOURG
0x042F	Macedonian (mk)	0x2F	LANG_MACEDONIAN	Macedonia, FYROM (MK)	0x01	SUBLANG_MACEDONIAN_MACEDONIA
0x083E	Malay (ms)	0x3E	LANG_MALAY	Brunei Darassalam (BN)	0x02	SUBLANG_MALAY_BRUNEI_DARUSSALAM
0x043e				Malaysia (MY)	0x01	SUBLANG_MALAY_MALAYSIA
0x044C	Malayalam (ml)	0x4C	LANG_MALAYALAM	India (IN)	0x01	SUBLANG_MALAYALAM_INDIA
0x043A	Maltese (mt)	0x3A	LANG_MALTESE	Malta (MT)	0x01	SUBLANG_MALTESE_MALTA
(reserved)	0x58	LANG_MANIPURI			
0x0481	Maori (mi)	0x81	LANG_MAORI	New Zealand (NZ)	0x01	SUBLANG_MAORI_NEW_ZEALAND
0x047A	Mapudungun (arn)	0x7A	LANG_MAPUDUNGUN	Chile (CL)	0x01	SUBLANG_MAPUDUNGUN_CHILE
0x044E	Marathi (mr)	0x4E	LANG_MARATHI	India (IN)	0x01	SUBLANG_MARATHI_INDIA
0x047C	Mohawk (moh)	0x7C	LANG_MOHAWK	Canada (CA)	0x01	SUBLANG_MOHAWK_MOHAWK
0x0450	Mongolian (mn)	0x50	LANG_MONGOLIAN	Mongolia, Cyrillic (MN)	0x01	SUBLANG_MONGOLIAN_CYRILLIC_MONGOLIA
0x0850				Mongolia, Mong (MN)	0x02	SUBLANG_MONGOLIAN_PRC
0x0461	Nepali (ne)	0x61	LANG_NEPALI	Nepal (NP)	0x01	SUBLANG_NEPALI_NEPAL
India (IN)	0x02	SUBLANG_NEPALI_INDIA
0x0414	Norwegian (no)	0x14	LANG_NORWEGIAN	Bokmål, Norway (NO)	0x01	SUBLANG_NORWEGIAN_BOKMAL
0x0814				Nynorsk, Norway (NO)	0x02	SUBLANG_NORWEGIAN_NYNORSK
0x0482	Occitan (oc)	0x82	LANG_OCCITAN	France (FR)	0x01	SUBLANG_OCCITAN_FRANCE
0x0448	Oriya (or)	0x48	LANG_ORIYA	India (IN)	0x01	SUBLANG_ORIYA_INDIA
0x0463	Pashto (ps)	0x63	LANG_PASHTO	Afghanistan (AF)	0x01	SUBLANG_PASHTO_AFGHANISTAN
0x0429	Persian (fa); see note 6	0x29	LANG_PERSIAN	Iran (IR)	0x01	SUBLANG_PERSIAN_IRAN
0x0415	Polish (pl)	0x15	LANG_POLISH	Poland (PL)	0x01	SUBLANG_POLISH_POLAND
0x0416	Portuguese (pt)	0x16	LANG_PORTUGUESE	Brazil (BR)	0x01	SUBLANG_PORTUGUESE_BRAZILIAN
0x0816				Portugal (PT); see note 7	0x02	SUBLANG_PORTUGUESE
0x0867	Pular (ff)	0x67	LANG_PULAR	Senegal (SN)	0x02	SUBLANG_PULAR_SENEGAL
0x0446	Punjabi (pa)	0x46	LANG_PUNJABI	India, Gurmukhi script (IN)	0x01	SUBLANG_PUNJABI_INDIA
0x0846				Pakistan, Arabic script(PK)	0x02	SUBLANG_PUNJABI_PAKISTAN
0x046B	Quechua (quz)	0x6B	LANG_QUECHUA	Bolivia (BO)	0x01	SUBLANG_QUECHUA_BOLIVIA
0x086B				Ecuador (EC)	0x02	SUBLANG_QUECHUA_ECUADOR
0x0C6B				Peru (PE)	0x03	SUBLANG_QUECHUA_PERU
0x0418	Romanian (ro)	0x18	LANG_ROMANIAN	Romania (RO)	0x01	SUBLANG_ROMANIAN_ROMANIA
0x0417	Romansh (rm)	0x17	LANG_ROMANSH	Switzerland (CH)	0x01	SUBLANG_ROMANSH_SWITZERLAND
0x0419	Russian (ru)	0x19	LANG_RUSSIAN	Russia (RU)	0x01	SUBLANG_RUSSIAN_RUSSIA
0x0485	Sakha (sah); see note 9	0x85	LANG_SAKHA	Russia (RU)	0x01	SUBLANG_SAKHA_RUSSIA
0x243B	Sami (smn)	0x3B	LANG_SAMI	Inari, Finland (FI)	0x09	SUBLANG_SAMI_INARI_FINLAND
0x103B	Sami (smj)			Lule, Norway (NO)	0x04	SUBLANG_SAMI_LULE_NORWAY
0x143B				Lule, Sweden (SE)	0x05	SUBLANG_SAMI_LULE_SWEDEN
0x0C3B	Sami (se)			Northern, Finland (FI)	0x03	SUBLANG_SAMI_NORTHERN_FINLAND
0x043B				Northern, Norway (NO)	0x01	SUBLANG_SAMI_NORTHERN_NORWAY
0x083B				Northern, Sweden (SE)	0x02	SUBLANG_SAMI_NORTHERN_SWEDEN
0x203B	Sami (sms)			Skolt, Finland (FI)	0x08	SUBLANG_SAMI_SKOLT_FINLAND
0x183B	Sami (sma)			Southern, Norway (NO)	0x06	SUBLANG_SAMI_SOUTHERN_NORWAY
0x1C3B				Southern, Sweden (SE)	0x07	SUBLANG_SAMI_SOUTHERN_SWEDEN
0x044F	Sanskrit (sa)	0x4F	LANG_SANSKRIT	India (IN)	0x01	SUBLANG_SANSKRIT_INDIA
0x7C1A	Serbian (sr); see note 2		LANG_SERBIAN_NEUTRAL	Neutral		
0x1C1A		0x1a	LANG_SERBIAN	Bosnia and Herzegovina, Cyrillic (BA)	0x07	SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_CYRILLIC
0x181A				Bosnia and Herzegovina, Latin (BA)	0x06	SUBLANG_SERBIAN_BOSNIA_HERZEGOVINA_LATIN
Croatia (HR)	0x01	SUBLANG_SERBIAN_CROATIA
0x0C1A				Serbia and Montenegro, Former, Cyrillic (CS)	0x03	SUBLANG_SERBIAN_CYRILLIC
0x081A				Serbia and Montenegro, Former, Latin (CS)	0x02	SUBLANG_SERBIAN_LATIN
0x046C	Sesotho sa Leboa (nso)	0x6C	LANG_SOTHO	South Africa (ZA)	0x01	SUBLANG_SOTHO_NORTHERN_SOUTH_AFRICA
0x0832	Setswana / Tswana (tn)	0x32	LANG_TSWANA	Botswana (BW)	0x02	SUBLANG_TSWANA_BOTSWANA
0x0432				South Africa (ZA)	0x01	SUBLANG_TSWANA_SOUTH_AFRICA
(reserved)	0x59	LANG_SINDHI	(reserved)	0x02	SUBLANG_SINDHI_AFGHANISTAN
0x0459	(reserved)			(reserved)	0x01	SUBLANG_SINDHI_INDIA
0x0859	Sindhi (sd)			Pakistan (PK)	0x02	SUBLANG_SINDHI_PAKISTAN
0x045B	Sinhala (si)	0x5B	LANG_SINHALESE	Sri Lanka (LK)	0x01	SUBLANG_SINHALESE_SRI_LANKA
0x041B	Slovak (sk)	0x1b	LANG_SLOVAK	Slovakia (SK)	0x01	SUBLANG_SLOVAK_SLOVAKIA
0x0424	Slovenian (sl)	0x24	LANG_SLOVENIAN	Slovenia (SI)	0x01	SUBLANG_SLOVENIAN_SLOVENIA
0x2C0A	Spanish (es)	0x0A	LANG_SPANISH	Argentina (AR)	0x0b	SUBLANG_SPANISH_ARGENTINA
0x400A				Bolivia (BO)	0x10	SUBLANG_SPANISH_BOLIVIA
0x340A				Chile (CL)	0x0D	SUBLANG_SPANISH_CHILE
0x240A				Colombia (CO)	0x09	SUBLANG_SPANISH_COLOMBIA
0x140A				Costa Rica (CR)	0x05	SUBLANG_SPANISH_COSTA_RICA
0x1C0A				Dominican Republic (DO)	0x07	SUBLANG_SPANISH_DOMINICAN_REPUBLIC
0x300A				Ecuador (EC)	0x0C	SUBLANG_SPANISH_ECUADOR
0x440A				El Salvador (SV)	0x11	SUBLANG_SPANISH_EL_SALVADOR
0x100A				Guatemala (GT)	0x04	SUBLANG_SPANISH_GUATEMALA
0x480A				Honduras (HN)	0x12	SUBLANG_SPANISH_HONDURAS
0x080A				Mexico (MX)	0x02	SUBLANG_SPANISH_MEXICAN
0x4C0A				Nicaragua (NI)	0x13	SUBLANG_SPANISH_NICARAGUA
0x180A				Panama (PA)	0x06	SUBLANG_SPANISH_PANAMA
0x3C0A				Paraguay (PY)	0x0F	SUBLANG_SPANISH_PARAGUAY
0x280A				Peru (PE)	0x0A	SUBLANG_SPANISH_PERU
0x500A				Puerto Rico (PR)	0x14	SUBLANG_SPANISH_PUERTO_RICO
0x0C0A				Spain, Modern Sort (ES)	0x03	SUBLANG_SPANISH_MODERN
0x040A				Spain, Traditional Sort (ES)	0x01	SUBLANG_SPANISH
0x540A				United States (US)	0x15	SUBLANG_SPANISH_US
0x380A				Uruguay (UY)	0x0E	SUBLANG_SPANISH_URUGUAY
0x200A				Venezuela (VE)	0x08	SUBLANG_SPANISH_VENEZUELA
0x0441	Swahili (sw)	0x41	LANG_SWAHILI	Kenya (KE)	0x01	SUBLANG_SWAHILI
0x081D	Swedish (sv)	0x1D	LANG_SWEDISH	Finland (FI)	0x02	SUBLANG_SWEDISH_FINLAND
0x041D				Sweden (SE); see note 8	0x01	SUBLANG_SWEDISH
0x041D				Sweden (SE); see note 8	0x01	SUBLANG_SWEDISH_SWEDEN
0x045A	Syriac (syr)	0x5A	LANG_SYRIAC	Syria (SY)	0x01	SUBLANG_SYRIAC
0x0428	Tajik (tg)	0x28	LANG_TAJIK	Tajikistan, Cyrillic (TJ)	0x01	SUBLANG_TAJIK_TAJIKISTAN
0x085F	Tamazight (tzm)	0x5F	LANG_TAMAZIGHT	Algeria, Latin (DZ)	0x02	SUBLANG_TAMAZIGHT_ALGERIA_LATIN
0x0449	Tamil (ta)	0x49	LANG_TAMIL	India (IN)	0x01	SUBLANG_TAMIL_INDIA
0x0849				Sri Lanka (LK)	0x02	SUBLANG_TAMIL_SRI_LANKA
0x0444	Tatar (tt)	0x44	LANG_TATAR	Russia (RU)	0x01	SUBLANG_TATAR_RUSSIA
0x044A	Telugu (te)	0x4A	LANG_TELUGU	India (IN)	0x01	SUBLANG_TELUGU_INDIA
0x041E	Thai (th)	0x1E	LANG_THAI	Thailand (TH)	0x01	SUBLANG_THAI_THAILAND
0x0451	Tibetan (bo)	0x51	LANG_TIBETAN	PRC (CN)	0x01	SUBLANG_TIBETAN_PRC
0x0873	Tigrinya (ti)	0x73	LANG_TIGRINYA	Eritrea (ER)	0x02	SUBLANG_TIGRINYA_ERITREA
0x0473				Ethiopia (ET)	0x01	SUBLANG_TIGRINYA_ETHIOPIA
0x0873	(reserved)	0x73	LANG_TIGRIGNA	(reserved)	0x02	SUBLANG_TIGRIGNA_ERITREA
0x041F	Turkish (tr)	0x1F	LANG_TURKISH	Turkey (TR)	0x01	SUBLANG_TURKISH_TURKEY
0x0442	Turkmen (tk)	0x42	LANG_TURKMEN	Turkmenistan (TM)	0x01	SUBLANG_TURKMEN_TURKMENISTAN
0x0422	Ukrainian (uk)	0x22	LANG_UKRAINIAN	Ukraine (UA)	0x01	SUBLANG_UKRAINIAN_UKRAINE
0x042E	Upper Sorbian (hsb)	0x2E	LANG_UPPER_SORBIAN	Germany (DE)	0x01	SUBLANG_UPPER_SORBIAN_GERMANY
0x0820	Urdu (ur)	0x20	LANG_URDU	(reserved)	0x02	SUBLANG_URDU_INDIA
0x0420				Pakistan (PK)	0x01	SUBLANG_URDU_PAKISTAN
0x0480	Uyghur (ug)	0x80	LANG_UIGHUR	PRC (CN)	0x01	SUBLANG_UIGHUR_PRC
0x0843	Uzbek (uz)	0x43	LANG_UZBEK	Uzbekistan, Cyrillic (UZ)	0x02	SUBLANG_UZBEK_CYRILLIC
0x0443				Uzbekistan, Latin (UZ)	0x01	SUBLANG_UZBEK_LATIN
0x0803	Valencian (ca)	0x03	LANG_VALENCIAN	Valencia (ES-Valencia)	0x02	SUBLANG_VALENCIAN_VALENCIA
0x042A	Vietnamese (vi)	0x2A	LANG_VIETNAMESE	Vietnam (VN)	0x01	SUBLANG_VIETNAMESE_VIETNAM
0x0452	Welsh (cy)	0x52	LANG_WELSH	United Kingdom (GB)	0x01	SUBLANG_WELSH_UNITED_KINGDOM
0x0488	Wolof (wo)	0x88	LANG_WOLOF	Senegal (SN)	0x01	SUBLANG_WOLOF_SENEGAL
0x0478	Yi (ii)	0x78	LANG_YI	PRC (CN)	0x01	SUBLANG_YI_PRC
0x046A	Yoruba (yo)	0x6A	LANG_YORUBA	Nigeria (NG)	0x01	SUBLANG_YORUBA_NIGERIA
"""

#TODO: resolve sublang. Note: sublangs indices are not unique, depends of lang
langs={}

for line in html.split("\n"):
	res=re.findall("(0x[^\s]+)\s+(LANG[^\s]+)",line)
	if len(res):
		langs[int(res[0][0],16)]=res[0][1]

def getLang(p_lang,s_lang):
	global langs
	lang=""
	if p_lang in langs:
		lang=langs[p_lang]
	if len(lang):
		return lang
	return "l%d_s%d" % (p_lang,s_lang)

#print ".rsrs_VA .rsrs_ptRawData"
print "type OffsetToData VirtualAddress Size fileOffset"

#find vaddress
va=0
ptrd=-1
for d in pe.OPTIONAL_HEADER.DATA_DIRECTORY:
	if d.name=="IMAGE_DIRECTORY_ENTRY_RESOURCE":
		va=d.VirtualAddress

#find the matching section
for s in pe.sections:
	if s.VirtualAddress==va:
		ptrd=s.PointerToRawData

for er in pe.DIRECTORY_ENTRY_RESOURCE.entries:
	for de in er.directory.entries:
		timedatestamp=de.directory.struct.TimeDateStamp
		for entry in de.directory.entries:
			res=entry.data.struct
			lang=getLang(entry.data.lang,entry.data.sublang)
			if ptrd==-1:
				print pefile.RESOURCE_TYPE.get(er.id),hex(va),hex(res.OffsetToData),res.Size,"?",lang,timedatestamp
			else:
				print pefile.RESOURCE_TYPE.get(er.id),hex(va),hex(res.OffsetToData),res.Size,hex(res.OffsetToData-va+ptrd),lang,timedatestamp

